﻿using LM.Negocio.Objetos;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace LM.Repositorios.Maps
{
    public class ItemTabelaDePrecoMap : EntityTypeConfiguration<ItemTabelaDePreco>
    {
        public ItemTabelaDePrecoMap()
        {
            //this.HasKey( m => m.Id );
            this.Property( m => m.Id ).HasDatabaseGeneratedOption( DatabaseGeneratedOption.Identity ).HasColumnName( "Id" );

            // Primary Key
            this.HasKey( t => t.Codigo );

            // Properties
            this.Property( t => t.Codigo ).HasDatabaseGeneratedOption( DatabaseGeneratedOption.None );
            this.Property( t => t.PeriodoInicial ).IsRequired().IsFixedLength().HasMaxLength( 10 );
            this.Property( t => t.PeriodoAdicional ).IsRequired().IsFixedLength().HasMaxLength( 10 );
            this.Property( t => t.Domingo ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Segunda ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Terca ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Quarta ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Quinta ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Sexta ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Sabado ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Matutino ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Vespertino ).IsFixedLength().HasMaxLength( 1 );
            this.Property( t => t.Noturno ).IsFixedLength().HasMaxLength( 1 );

            // Table & Column Mappings
            this.ToTable( "ITEMDETABELA" );
            this.Property( t => t.Id ).HasColumnName( "Id" );
            this.Property( t => t.Codigo ).HasColumnName( "Codigo" );
            this.Property( t => t.TipoVeiculoId ).HasColumnName( "TipoVeiculoId" );
            this.Property( t => t.TipoVagaId ).HasColumnName( "TipoVagaId" );
            this.Property( t => t.PeriodoInicial ).HasColumnName( "PeriodoInicial" );
            this.Property( t => t.CustoPeriodoInicial ).HasColumnName( "CustoPeriodoInicial" );
            this.Property( t => t.PeriodoAdicional ).HasColumnName( "PeriodoAdicional" );
            this.Property( t => t.CustoPeriodoAdicional ).HasColumnName( "CustoPeriodoAdicional" );
            this.Property( t => t.Domingo ).HasColumnName( "Domingo" );
            this.Property( t => t.Segunda ).HasColumnName( "Segunda" );
            this.Property( t => t.Terca ).HasColumnName( "Terca" );
            this.Property( t => t.Quarta ).HasColumnName( "Quarta" );
            this.Property( t => t.Quinta ).HasColumnName( "Quinta" );
            this.Property( t => t.Sexta ).HasColumnName( "Sexta" );
            this.Property( t => t.Sabado ).HasColumnName( "Sabado" );
            this.Property( t => t.Matutino ).HasColumnName( "Matutino" );
            this.Property( t => t.Vespertino ).HasColumnName( "Vespertino" );
            this.Property( t => t.Noturno ).HasColumnName( "Noturno" );
            this.Property( t => t.TabelaPrecoId ).HasColumnName( "TabelaPrecoId" );

            // Relationships
            this.HasRequired( t => t.TabelaPreco ).WithMany( t => t.ItensTabela ).HasForeignKey( d => d.TabelaPrecoId );
            this.HasRequired( t => t.TipoVeiculo ).WithMany( t => t.ItensTabela ).HasForeignKey( d => d.TipoVeiculoId );
            this.HasRequired( t => t.Vaga ).WithMany( t => t.ItensTabela ).HasForeignKey( d => d.TipoVagaId );
        }
    }
}
